package com.choosefine.base.shixiaobao.base;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.MongoTemplate;

import com.choosefine.base.shixiaobao.common.utils.MessageSourceUtils;

/**
 * Service
 * 
 * @author guwenwei
 * 
 */
public class BaseService{
	
	@Value("#{yaml.get('service.shixiaobao.url')}")
	public String shixiaobaoURL=null;

	@Value("#{yaml.get('service.shopping.url')}")
	public String shoppingURL=null;

	@Value("#{yaml.get('service.console.url')}")
	public String consoleURL=null;

	@Value("#{yaml.get('service.usercent.url')}")
	public String usercentURL=null;

	@Value("#{yaml.get('service.push.url')}")
	public String pushURL=null;
	
	@Value("#{yaml.get('service.pay.url')}")
	public String payURL = null;

	@Value("#{yaml.get('service.communication.url')}")
	public String communicationURL=null;

	@Autowired
	public MessageSourceUtils messageSourceUtils;

	@Autowired
	public MongoTemplate mongoTemplate;

//	@Autowired
//	private AccountMapper accountMapper;
//	/**
//	 *  
//	 *
//	 * @Description：用于控制台代发布，操作员编号校验
//	 * @Author：juchengyang
//	 * @Create Date：2017-03-29
//	 */
//	public void publisherCheck(String publisher) {
//		int count = accountMapper.checkPublisher(publisher);
//		Assert.assertFalse(count == 0, messageSourceUtils.getMessage("shixiaobao.exception.msg_usernotexit"));
//	}
	
	/**
	 * 根据公司类型及公司编号判断公司是否存在
	 *
	 * @Author：liaozhanggen
	 * @Create Date：2017年3月27日
	 * @param：....
	 * @return：void
	 *//*
	public CompanyInfo companyInfoUserCodeCheck (CompanyInfo info) {
		CompanyInfo cInfo = companyInfomapper.findCompanyUnitExistsByUserCode(info);
		Assert.assertFalse(cInfo  ==  null, messageSourceUtils.getMessage("shixiaobao.exception.msg_usernotexit"));
		return cInfo;
	}
	public CompanyInfo companyInfo (CompanyInfo info) {
		return companyInfomapper.findCompanyUnitExistsByUserCode(info);
	}


	*//**
	 * 增加时验证 companyUserCode是否存在 不存在才增加
	 *  yuxin 3.31
	 *//*
	public void companyInfoUserCodeCheckIsValid (String userCode) {
		CompanyInfo companyInfo = mongoTemplate.findOne(new Query(Criteria.where("userCode").is(userCode)),CompanyInfo.class);
		Assert.assertNull(companyInfo, messageSourceUtils.getMessage("shixiaobao.basedata.Company.userCode.exists.error"));
	}
	//查询公司名字是否存在yuxin3.31
	public void checkCompanyName(String companyName,int companyType){
		Criteria criteria=new Criteria();
		criteria.and("companyName").is(companyName);
		criteria.and("companyType").is(companyType);
		CompanyInfo companyInfo = mongoTemplate.findOne(new Query(criteria),CompanyInfo.class);
		Assert.assertNull(companyInfo,messageSourceUtils.getMessage("shixiaobao.basedata.Company.companyName.exists.error"));
	}
	//查询公司名字是否存在yuxin3.31
	public void checkCompanyNameUpdate(String companyName,int companyType,int id){
		Criteria criteria=new Criteria();
		criteria.and("companyName").is(companyName);
		criteria.and("companyType").is(companyType);
		criteria.and("_id").nin(id);
		CompanyInfo companyInfo = mongoTemplate.findOne(new Query(criteria),CompanyInfo.class);
		Assert.assertNull(companyInfo,messageSourceUtils.getMessage("shixiaobao.basedata.Company.companyName.exists.error"));
	}
	//查询企业简称是否存在yuxin3.31
	public void checkCompanyShortname(String companyShortname,int companyType){
		Criteria criteria=new Criteria();
		criteria.and("companyShortname").is(companyShortname);
		criteria.and("companyType").is(companyType);
		CompanyInfo companyInfo = mongoTemplate.findOne(new Query(criteria),CompanyInfo.class);
		Assert.assertNull(companyInfo,messageSourceUtils.getMessage("shixiaobao.basedata.Company.companyShortname.exists.error"));
	}
	//查询企业简称是否存在yuxin3.31
	public void checkCompanyShortnameUpdate(String companyShortname,int companyType,int id){
		Criteria criteria=new Criteria();
		criteria.and("companyShortname").is(companyShortname);
		criteria.and("companyType").is(companyType);
		criteria.and("_id").nin(id);
		CompanyInfo companyInfo = mongoTemplate.findOne(new Query(criteria),CompanyInfo.class);
		Assert.assertNull(companyInfo,messageSourceUtils.getMessage("shixiaobao.basedata.Company.companyShortname.exists.error"));
	}*/
}
